package com.wdh.kjs.activity;

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;
import android.widget.TextView;

import com.wdh.kjs.R;
import com.wdh.kjs.fragment.Im_investrecord_Fragment;
import com.wdh.kjs.fragment.Im_raisestop_Fragment;
import com.wdh.kjs.fragment.Im_raisesuccess_Fragment;
import com.wdh.kjs.fragment.Im_raising_Fragment;

/**
 * Created by CQH on 2016/4/21.
 */
public class InvestManageActivity extends BaseTopActivity implements View.OnClickListener{
    private TextView bt_id_investmentrecord;
    private TextView bt_id_raising;
    private TextView bt_id_raisesuccess;
    private TextView bt_id_raisestop;
    private FragmentManager manager;
    private FragmentTransaction transaction;
    private Im_investrecord_Fragment fragmentOne;
    private Im_raising_Fragment fragmentTwo;
    private Im_raisesuccess_Fragment fragmentThree;
    private Im_raisestop_Fragment fragmentFour;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_investmentmanage);
        initTopBar("投资管理");
        initView();
    }

    public void initView(){
        bt_id_investmentrecord = (TextView)findViewById(R.id.bt_id_investmentrecord);
        bt_id_raising = (TextView)findViewById(R.id.bt_id_raising);
        bt_id_raisesuccess = (TextView)findViewById(R.id.bt_id_raisesuccess);
        bt_id_raisestop = (TextView)findViewById(R.id.bt_id_raisestop);

        bt_id_investmentrecord.setOnClickListener(this);
        bt_id_raising.setOnClickListener(this);
        bt_id_raisesuccess.setOnClickListener(this);
        bt_id_raisestop.setOnClickListener(this);

        manager=getFragmentManager();
        transaction=manager.beginTransaction();
        fragmentOne=new Im_investrecord_Fragment();
        transaction.add(R.id.im_id_list, fragmentOne);
        transaction.commit();
        bt_id_investmentrecord.setTextColor(getResources().getColor(R.color.blue_light));
    }

    @Override
    public void onClick(View view) {
        transaction=manager.beginTransaction();
        switch (view.getId())
        {
            case R.id.bt_id_investmentrecord:
                bt_id_investmentrecord.setTextColor(getResources().getColor(R.color.blue_light));
                bt_id_raising.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_raisesuccess.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_raisestop.setTextColor(getResources().getColor(R.color.text_color));
                fragmentOne=new Im_investrecord_Fragment();
                transaction.replace(R.id.im_id_list, fragmentOne, "fragmentOne");
                transaction.addToBackStack("fragmentOne");
                break;
            case R.id.bt_id_raising:
                bt_id_investmentrecord.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_raising.setTextColor(getResources().getColor(R.color.blue_light));
                bt_id_raisesuccess.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_raisestop.setTextColor(getResources().getColor(R.color.text_color));
                fragmentTwo=new Im_raising_Fragment();
                transaction.replace(R.id.im_id_list, fragmentTwo, "fragmentTwo");
                transaction.addToBackStack("fragmentTwo");
                break;
            case R.id.bt_id_raisesuccess:
                bt_id_investmentrecord.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_raising.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_raisesuccess.setTextColor(getResources().getColor(R.color.blue_light));
                bt_id_raisestop.setTextColor(getResources().getColor(R.color.text_color));
                fragmentThree=new Im_raisesuccess_Fragment();
                transaction.replace(R.id.im_id_list, fragmentThree, "fragmentThree");
                transaction.addToBackStack("fragmentThree");
                break;
            case R.id.bt_id_raisestop:
                bt_id_investmentrecord.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_raising.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_raisesuccess.setTextColor(getResources().getColor(R.color.text_color));
                bt_id_raisestop.setTextColor(getResources().getColor(R.color.blue_light));
                fragmentFour=new Im_raisestop_Fragment();
                transaction.replace(R.id.im_id_list, fragmentFour, "fragmentFour");
                transaction.addToBackStack("fragmentFour");
                break;
        }
        transaction.commit();
    }
}
